package com.lik888.web1.controller;


import com.lik888.web1.entity.DTO.EsPageDTO;
import com.lik888.web1.entity.ESTable;
import com.lik888.web1.entity.R;
import com.lik888.web1.entity.VO.PageVo;
import com.lik888.web1.service.IGoodsTableService;
import lombok.RequiredArgsConstructor;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.io.IOException;

@RestController
@RequestMapping("/search")
@RequiredArgsConstructor
public class ElasticSearchController {
    private final IGoodsTableService goodsTableService;
    @PostMapping("/goods")
    @PreAuthorize("hasAuthority('user')")
    public R searchGoods(@RequestBody EsPageDTO esPageDTO) throws IOException {
        PageVo pageVo = goodsTableService.SearchGoods(esPageDTO);
        return R.ok(pageVo);
    }
}
